
package com.shop.cloud.mall.admin.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shop.cloud.common.core.util.R;
import com.shop.cloud.common.log.annotation.SysLog;
import com.shop.cloud.mall.common.entity.UserShopLabel;
import com.shop.cloud.mall.admin.service.UserShopLabelService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

/**
 * 店铺用户标签
 *
 * @author 
 * @date 2023-07-17 15:50:13
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/usershoplabel")
@Tag(description = "usershoplabel", name = "店铺用户标签管理")
public class UserShopLabelController {

    private final UserShopLabelService userShopLabelService;

    /**
     * 店铺用户标签分页列表
     * @param page 分页对象
     * @param userShopLabel 店铺用户标签
     * @return
     */
    @Operation(summary = "店铺用户标签分页列表")
    @GetMapping("/page")
    @PreAuthorize("@ato.hasAuthority('mall:usershoplabel:index')")
    public R getPage(Page page, UserShopLabel userShopLabel) {
        return R.ok(userShopLabelService.page(page, Wrappers.query(userShopLabel)));
    }

    /**
     * 店铺用户标签list
     * @param userShopLabel 店铺用户标签
     * @return
     */
    @Operation(summary = "店铺用户标签list")
    @GetMapping("/list")
    public R getList(UserShopLabel userShopLabel) {
        return R.ok(userShopLabelService.list(Wrappers.query(userShopLabel)));
    }

    /**
     * 店铺用户标签查询
     * @param id
     * @return R
     */
    @Operation(summary = "店铺用户标签查询")
    @GetMapping("/{id}")
    @PreAuthorize("@ato.hasAuthority('mall:usershoplabel:get')")
    public R getById(@PathVariable("id") String id) {
        return R.ok(userShopLabelService.getById(id));
    }

    /**
     * 店铺用户标签新增
     * @param userShopLabel 店铺用户标签
     * @return R
     */
    @Operation(summary = "店铺用户标签新增")
    @SysLog("新增店铺用户标签")
    @PostMapping
    @PreAuthorize("@ato.hasAuthority('mall:usershoplabel:add')")
    public R save(@RequestBody UserShopLabel userShopLabel) {
        return R.ok(userShopLabelService.save(userShopLabel));
    }

    /**
     * 店铺用户标签修改
     * @param userShopLabel 店铺用户标签
     * @return R
     */
    @Operation(summary = "店铺用户标签修改")
    @SysLog("修改店铺用户标签")
    @PutMapping
    @PreAuthorize("@ato.hasAuthority('mall:usershoplabel:edit')")
    public R updateById(@RequestBody UserShopLabel userShopLabel) {
        return R.ok(userShopLabelService.updateById(userShopLabel));
    }

    /**
     * 店铺用户标签删除
     * @param id
     * @return R
     */
    @Operation(summary = "店铺用户标签删除")
    @SysLog("删除店铺用户标签")
    @DeleteMapping("/{id}")
    @PreAuthorize("@ato.hasAuthority('mall:usershoplabel:del')")
    public R removeById(@PathVariable String id) {
        return R.ok(userShopLabelService.removeById(id));
    }

}
